{% extends 'base.html' %}

{% block extrahead %}
{% if place %}
<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="rss/">
{% endif %}
<script src="http://maps.google.com/maps?file=api&amp;v=2.x&amp;key={{gmaps_key}}" type="text/javascript"></script>
<style type="text/css">v\:* {behavior:url(#default#VML);}</style>
<script type="text/javascript">
//<![CDATA[


function init_maps() {
    {% if ward_map %}
    var m1 = new {{ ward_map.markers.0 }};
    var gx1 = new GGeoXml('{{ward_map.kml_urls.0}}');
    var map1 = new GMap2(document.getElementById('ward_map'));
    //gmap_load(map, m2, gx);
    map1.setCenter(new GLatLng(0, 0), 1);
    map1.addOverlay(m1);
    map1.addOverlay(gx1);
    map1.addControl(new GSmallMapControl());
    map1.disableInfoWindow();
    GEvent.addListener(gx1, "load", function() {
        this.gotoDefaultViewport( map1 ); 
    })
    {% endif %}

    {% if house_map %}
    var m2 = new {{ house_map.markers.0 }};
    var gx2= new GGeoXml('{{house_map.kml_urls.0}}');
    //gmap_load('house_map', gx1, m2);
    var map2 = new GMap2(document.getElementById('house_map'));
    map2.setCenter(new GLatLng(0, 0), 1);
    map2.addOverlay(m2);
    map2.addOverlay(gx2);
    map2.addControl(new GSmallMapControl());
    map2.disableInfoWindow();
    GEvent.addListener(gx2, "load", function() {
        this.gotoDefaultViewport( map2 ); 
    })
    {% endif %}

    {% if senate_map %}
    var m3 = new {{ senate_map.markers.0 }};
    var gx3= new GGeoXml('{{senate_map.kml_urls.0}}');
    //gmap_load('houses_map', gx1, m2);
    var map3 = new GMap2(document.getElementById('senate_map'));
    map3.setCenter(new GLatLng(0, 0), 1);
    map3.addOverlay(m3);
    map3.addOverlay(gx3);
    map3.addControl(new GSmallMapControl());
    map3.disableInfoWindow();
    GEvent.addListener(gx3, "load", function() {
        this.gotoDefaultViewport( map3 ); 
    })
    {% endif %}

    {% if congress_map %}
    var m4 = new {{ congress_map.markers.0 }};
    var gx4= new GGeoXml('{{congress_map.kml_urls.0}}');
    //gmap_load('houses_map', gx1, m2);
    var map4 = new GMap2(document.getElementById('congress_map'));
    map4.setCenter(new GLatLng(0, 0), 1);
    map4.addOverlay(m4);
    map4.addOverlay(gx4);
    map4.addControl(new GSmallMapControl());
    map4.disableInfoWindow();
    GEvent.addListener(gx4, "load", function() {
        this.gotoDefaultViewport( map4 ); 
    })
    {% endif %}
}
//]]>
</script>
{% endblock %}

{% block title %}{% if place %}Politics for {{place}} | {% else %}{{block.super}}{% endif %}{% endblock %}

{% block bodytag %}<body onload="init_maps()" onunload="GUnload()" id="page_detail">{% endblock %}

{% block heading %}
<h1 id="logo"><a href="/"><img src="{{MEDIA_URL}}img/logos/replogo_m.gif" alt="RepSheet" /></a></h1>
{% endblock %}

{% block content %}
{% if place %}

    <h1 id="location">{{place}} <a href="/">change address</a></h1>

    <div id="maps">
    <h1>Maps</h1>
    <ul>
    {% if ward_map %}
    <li><h2>{{ward}}</h2>
    <div id="{{ ward_map.dom_id }}" 
             style="width:340px;height:200px;"></div></li>
    {% endif %}
    {% if house_map %}
    <li><h2>{{house}}</h2>
    <div id="{{ house_map.dom_id }}" 
             style="width:340px;height:200px;"></div></li>
    {% endif %}
    {% if senate_map %}
    <li><h2>{{senate}}</h2><div id="{{ senate_map.dom_id }}" 
             style="width:340px;height:200px;"></div></li>
    {% endif %}
    {% if congress_map %}
    <li><h2>{{congress}}</h2><div id="{{ congress_map.dom_id }}" 
             style="width:340px;height:200px;"></div></li>
    {% endif %}
    </ul>
    </div>

    <div id="left_col">
    <div id="who">
    <table>
    {% if not ward and not senate and not congress and not house %}
    <h2>Sorry, there is no data on your location yet.</h2>
    {% else %}
    <thead><tr><th>You live in...</th><th>You are represented by...</th><th>They can be found at...</th><th>And contacted...</th></tr></thead>
    <tbody>
    {% endif %}
    {% if ward %}
    <tr class="{% cycle 'row1' 'row2' as rowcolors %}">
    <td>{{ward}} (Alderman)</td>
    <td class="name"><a href="{% url repsheet_rep_detail ward.rep.slug %}"
    >{{ward.rep|title}}</a></td>
    <td>{{ward.address}}</td>
    <td>Ward:&nbsp;{{ward.ward_phone}}<br/>City&nbsp;Hall:&nbsp;{{ward.hall_phone}}</td>
    </tr>
    {% endif %}

    {% if house %}
    <tr class="{% cycle rowcolors %}">
    <td>{{house}}</td>
    <td class="name"><a href="{% url repsheet_rep_detail house.rep.slug %}"
    >{{house.name|title}}</a></td>
    <td>{{house.address}}</td>
    <td>{{house.telephone}}</td>
    </tr>
    {% endif %}

    {% if senate %}
    <tr class="{% cycle rowcolors %}">
    <td>{{senate}}</td>
    <td class="name"><a href="{% url repsheet_rep_detail senate.rep.slug %}"
    >{{senate.name|title}}</a></td>
    <td>{{senate.address}}</td>
    <td>{{senate.telephone}}</td>
    </tr>
    {% endif %}

    {% if congress %}
    <tr class="{% cycle rowcolors %}">
    <td>{{congress}}</td>
    <td class="name"><a href="{% url repsheet_rep_detail congress.rep.slug %}"
    >{{congress.name|title}}</a></td>
    <td>{{congress.address}}</td>
    <td>{{congress.telephone}}</td>
    </dl>
    </td></tr>
    {% endif %}

    </tbody></table>
    </div>

    {% if news %}
    <div id="news">
    <h1>Recent press for your representatives</h1> 
    <p id="hooks">
    <a id="hook_email" href="sub/">E-mail Alerts</a>
    <a id="hook_feed" href="rss/">RSS Feed for Your Reps</a> 
    </p>
    <h2>{{news|length}} articles found this week</h2>
    <ul>
    {% for n in news %}
    <li><h3><a href="{{n.link|safe}}">{{n.title|safe}}</a></h3>
    <p><span class="pub">{{n.publication}}</span> - {{n.date_modified|date:"N j, Y P"}}</p> 
    <p class="summary">{{n.summary|safe}}</p></li>
    {% endfor %}
    </ul>

    <div id="ads">
    {% if not debug %}
    <script type="text/javascript"><!--
    google_ad_client = "pub-2451239973624610";
    /* RepSheet Scraper */
    google_ad_slot = "6443035431";
    google_ad_width = 160;
    google_ad_height = 600;
    //-->
    </script>
    <script type="text/javascript"
    src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script>
    {% endif %}
    </div>

    </div>
    {% endif %}

    </div><!-- close left_col -->

<div class="footi">
<form action="{% url repsheet_lookup %}" id="search_form_foot">
<div>
{{form}}
</div>
<input type="submit" value="Go" id="submit" />
</form>
</div>
{% else %}
{% endif %}

{% endblock %}
